<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>登录</title>
    <link href="/static/vj/css/jqueryui.css" rel="stylesheet" type="text/css"/>
    <link href="/static/vj/css/vjpublic.css" rel="stylesheet" type="text/css"/>
    <link href="/static/vj/css/vjpage.css" rel="stylesheet" type="text/css"/>
    <link href="/static/vj/css/config.css" rel="stylesheet" type="text/css"/>
    <link href="/static/layui/css/layui.css" rel="stylesheet" type="text/css"/>
</head>
<body data-curpagename="page1" class="body_style1">
<div id="login_jPanel1" class="Panel Panel_Null">
    <div id="login_jPanel2" class="Panel Panel_Null">
        <div id="login_jHtmlForm1_form">
            <form id="login_jHtmlForm1" class="layui-form" name="login_jHtmlForm1">
                <div class="layui-form-item">
                    <div id="login_jLabel1" class="text">用户名：</div>
                    <input type="text" name="username" placeholder="请输入用户名" lay-verify="required|username" class="Edit Edit_style1" id="login_jEdit1"/>
                </div>
                <div class="layui-form-item">
                    <div id="login_jLabel2" class="text">密码：</div>
                    <input type="password" name="password" placeholder="请输入密码" lay-verify="required|password" class="Edit Edit_style4" id="login_jEdit2"/>
                </div>
                <div class="layui-form-item">
                    <div id="login_jButton1" class="vjbutton vjbutton_c_style1 border_radius_3">
                        <div class="vjbutton_txtR" lay-submit lay-filter="submit_Login">登录</div>
                    </div>
                    <div id="login_jButton2" class="vjbutton vjbutton_c_style1 border_radius_3">
                        <div class="vjbutton_txtR">退出</div>
                    </div>
                </div>
            </form>
        </div>
        <div id="login_jLabel3" class="text">教育管理系统</div>
    </div>
</div>

<script type="text/javascript" src="/static/vj/js/public.js"></script>
<script type="text/javascript" src="/static/vj/js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="/static/vj/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script>
    layui.use(['form','layer','util'], function () {
        var $ = layui.$;
        var forms = layui.form;
        var layers = layui.layer;
        /* 表单提交 */
        var on = forms.on("submit(submit_Login)", function (data) {
            /*      console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
                    console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
                     console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
                    return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。 */
            /* 将数据提交到manage/user/login接口 */
            var index = layers.load(2);
            $.ajax({
                type:'POST',
                url:'/manage/login',
                data:data.field,
                success:function(data){
                    console.log(data);
                    if (data.status == 100){
                        layers.close(index);
                        location.href="/manage/indexPage" ;
                    }
                    if (data.status == 101){
                        layers.close(index);
                        layers.msg("帐号或密码错误");
                        $("[name=username]").val("");
                        $("[name=password]").val("");
                    }
                    if (data.status == 103){
                        layers.close(index);
                        layers.msg("帐号或密码未输入");
                        $("[name=username]").val("");
                        $("[name=password]").val("");
                    }
                },
                error:function(data){
                    layers.close(index);
                    layers.msg("服务器错误");
                    $("[name=username]").val("");
                    $("[name=password]").val("");
                }
            });
        });

        /* 自定义验证规则 */
        forms.verify({

            /* 用户名 */
            username:function(value,item){  /* value：表单的值、item：表单的DOM对象 */

                /* 验证用户密码的内容 */
                if (!new RegExp("(?!^\d+$)(?!^[a-zA-Z]+$)[0-9a-zA-Z]{6,16}").test(value)){
                    return "请输入正确的用户名";
                }
            },

            /* 验证密码 */
            password:function(value,item){
                /* 验证用户密码的复杂度 */

                /* 验证用户密码的内容 */
                if (!new RegExp("(?!^\d+$)(?!^[a-zA-Z]+$)[0-9a-zA-Z]{6,16}").test(value)){
                    return "请输入正确的密码";
                }
            }
        });


    });
</script>
</body>
</html>